const pluginName = 'ConsoleLogOnBuildWebpackPlugin';

class ConsoleLogOnBuildWebpackPlugin {
  apply(compiler) {
    // build
    compiler.hooks.run.tap(pluginName, (compilation) => {
      console.log('@@@compilation', compilation.stats);
      console.log('webpack build');
    });
    // dev
    compiler.hooks.compilation.tap(pluginName, (compilation) => {
      // console.log('@@@compilation', compilation.getStats());
      console.log('webpack dev');
    });
    compiler.hooks.entryOption.tap(pluginName, (compilation) => {
      // console.log('@@@compilation', compilation.getStats());
      console.log('webpack entryOption');
    });
    compiler.hooks.afterPlugins.tap(pluginName, (compilation) => {
      // console.log('@@@compilation', compilation.getStats());
      console.log('webpack afterPlugins');
    });
    // TODO hooks 中的方法为什么在环境不同时做法不同。

  }
}

module.exports = ConsoleLogOnBuildWebpackPlugin;